<?php
/**
 * Controller is the customized base controller class.
 * All controller classes for this application should extend from this base class.
 * @author MarcusMao who works for SunyardBpo
 */

class Controller extends CController
{
	/**
	 * @var string the default layout for the controller view. Defaults to '//layouts/column1',
	 * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
	 */
	public $layout='//layouts/basic';


	public $user = null;
	public function init()
	{
	    $this->user = app()->user->getDbData();
	
	    return parent::init();
	}
	
	
	public function filters()
	{
		return array(
			'AccessControl' // make filterAccessControl method come into force
		);
	}
	
	public function filterAccessControl($filterChain)
	{
        $filter=new AccessControlFilter;  // changed this
        $filter->setRules($this->accessRules());
        $filter->filter($filterChain);
	}

	
	protected function _returnAjax($msg = '', $byJson = true)
	{
		if($byJson){
			$msg = json_encode($msg);
		}
		echo $msg;
		$this->_end();
	}
    
	protected function _end($msg = '', $status=0, $exit=true)
	{
	    echo $msg;
		if($exit)
			exit($status);
	}
}